<template>
  <div>
    <el-card class="box-card">
      <el-form :inline="true">
        <el-form-item label="一级分类">
          <el-select
            placeholder="请选择"
            v-model="categoryStore.c1Id"
            :disabled="scene == 0 ? false : true"
            @change="handler"
          >
            <el-option
              :label="item.name"
              v-for="item in categoryStore.c1Arr"
              :key="item.id"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="二级分类">
          <el-select
            placeholder="请选择"
            @change="handlers"
            :disabled="scene == 0 ? false : true"
            v-model="categoryStore.c2Id"
          >
            <el-option
              :label="item.name"
              v-for="item in categoryStore.c2Arr"
              :key="item.id"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="三级分类">
          <el-select
            placeholder="请选择"
            v-model="categoryStore.c3Id"
            :disabled="scene == 0 ? false : true"
          >
            <el-option
              :label="item.name"
              v-for="item in categoryStore.c3Arr"
              :key="item.id"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue'
import useCategoryStore from '@/store/modules/category'
let categoryStore = useCategoryStore()
onMounted(() => {
  getC1()
})
const getC1 = async () => {
  //获取一级下拉
  categoryStore.getC1()
}
const handler = () => {
  //
  categoryStore.c2Id = ''
  categoryStore.c3Id = ''
  categoryStore.c3Arr = []
  //一级下拉获取二级
  categoryStore.getC2()
}
const handlers = () => {
  categoryStore.c3Id = ''
  //二级下拉获取三级
  categoryStore.getC3()
}
defineProps(['scene'])
</script>
<style lang="scss" scoped></style>
